//
//  HYImageTableViewCell.m
//  Booking
//
//  Created by Duntech on 2018/4/23.
//  Copyright © 2018年 Duntech. All rights reserved.
//

#import "HYImageTableViewCell.h"

@interface HYImageTableViewCell ()

@property (nonatomic,strong) UIImageView *imgView;

@property (nonatomic,strong) UIImageView *bgImgView;

@end

@implementation HYImageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self.contentView addSubview:self.imgView];
        [self.contentView addSubview:self.bgImgView];
        
        [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
        
        [_bgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
    }
    return self;
}

- (void)configWithModel:(id)model{
    
    HYImageCellModel *cellModel = (HYImageCellModel *)model;
    [_imgView sd_setImageWithURL:[NSURL URLWithString:cellModel.imgUrl] placeholderImage:[UIImage imageNamed:@"image_placeholder"]];
    
    _bgImgView.hidden = !cellModel.isBgImg;
}

- (UIImageView *)imgView{
    
    if (!_imgView) {
        
        _imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image_placeholder"]];
        _imgView.contentMode = UIViewContentModeScaleAspectFill;
        _imgView.clipsToBounds = YES;
    }
    return _imgView;
}

-(UIImageView *)bgImgView{
    if (!_bgImgView) {
        _bgImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"img_Ornament"]];
        _bgImgView.clipsToBounds = YES;
    }
    return _bgImgView;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

@implementation HYImageCellModel

@end
